<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form layui-form-pane1" action="{:url('apply_detail')}" method="post"
          enctype="multipart/form-data">
        <div class="layui-collapse" lay-filter="driver">
            <!--<div class="layui-colla-item">-->
            <div class="">
                <h2 class="layui-colla-title" data-v="driver">申请人信息</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table">
                        <tr>
                            <td style="width: 118px;text-align: center;">姓名</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="username" class="layui-input" value="{$info['username']}" lay-verify="required" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">手机号</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="phone" class="layui-input" value="{$info['phone']}" maxlength="11" lay-verify="required||number" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">备用号码</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="backup_phone" class="layui-input" value="{$info['backup_phone']?:'';}" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">加盟性质</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <select name="type" id="type" lay-filter="type" lay-verify="required"
                                                class="layui-input-inline" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>
                                            <if condition="isset($info['type'])">
                                                <option value="{$info['type']}"><if condition="$info['type'] eq 1">个人<elseif condition="$info['type'] eq 2"/>公司<else/>组织</if>
                                                </option>
                                            </if>
                                            <option value="">请选择性质</option>
                                            <option value="1">个人</option>
                                            <option value="2">公司</option>
                                            <option value="3">组织</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline" id="type_info">
                                        <input type="text" name="type_info" value="{$info['type_info']}"
                                               class="layui-input" placeholder="请填写公司或组织名称" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>
                                    </div>
                                </div>
                            </td>
                        <tr>
                            <td style="text-align: center;">加盟地址</td>
                            <td>
                                <div class="layui-inline">
                                    <select name="province_id" id="province_id" lay-verify="required" lay-filter="province" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>
                                        <if condition="$info['province_id']">
                                            <option value="{$info['province_id']}">{$info['province_name']}</option>
                                            <else />
                                            <option value="">请选择省份</option>
                                        </if>
                                        <volist name="$info['province']" id="vo">
                                            <option value="{$vo['region_id']}">{$vo['region_name']}</option>
                                        </volist>
                                    </select>
                                </div>

                                <div class="layui-inline">
                                    <select name="city_id" id="city_id" lay-filter="city" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>
                                        <if condition="$info['city_id']">
                                            <option value="{$info['city_id']}">{$info['city_name']}</option>
                                            <else />
                                            <option value="">请选择城市</option>
                                        </if>
                                    </select>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">车辆资源</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="car_num" value="{$info['car_num']}" class="layui-input"
                                               lay-verify="required|number" placeholder="车辆数" lay-filter="car_num" onchange="changeInfo()" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="car_model" value="{$info['car_model']}"
                                               class="layui-input" placeholder="车辆型号" <if condition="$info['is_car'] neq 0">lay-verify="required"</if> <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">司机资源</td>
                            <td>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="driver_num" value="{$info['driver_num']}"
                                               class="layui-input" lay-verify="required|number" placeholder="司机人数"  <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>/>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">其他资源</td>
                            <td>
                                <textarea placeholder="请输入内容" class="layui-textarea"
                                          name="other_resource" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if> >{$info['other_resource']}</textarea>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="">
                <h2 class="layui-colla-title" data-v="car" data-value="">处理详情</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table">
                        <tr>
                            <td style="width: 118px;text-align: center;">表单ID</td>
                            <td>{$info['id']}</td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">处理人</td>
                            <td>{$info['deal_name']}</td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">领取任务时间</td>
                            <td>{$info['get_task_time']}</td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">目前进度</td>
                            <td>
                                <div class="layui-input-inline progress">
                                    <input type="radio" name="progress" value="2" title="处理中" lay-filter="progress"
                                    <if condition="$info['progress'] eq 2">checked="checked"</if> <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>
                                    >
                                    <input type="radio" name="progress" value="3" title="已处理" lay-filter="progress"
                                    <if condition="$info['progress'] eq 3">checked="checked"</if> <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>
                                    >
                                </div>
                            </td>
                        </tr>
                        <tr class="result">
                            <td style="text-align: center;">处理结果</td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="radio" name="deal_result" value="1" title="通过" checked <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>
                                    <input type="radio" name="deal_result" value="2" title="不通过"
                                    <if condition="$info['deal_result'] eq 2">checked="checked"</if> <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>
                                    >
                                </div>
                            </td>
                        </tr>
                        <tr class="result">
                            <td style="text-align: center;">备注</td>
                            <td>
                                <textarea placeholder="请输入内容" class="layui-textarea"
                                          name="remark" <if condition="$info['login_admin_name'] neq $info['deal_name']">disabled="disabled"</if>>{$info['remark']}</textarea>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" value="{$info['id']}" name="id">
                    <button class="layui-btn" lay-submit="edit" lay-filter="edit" <if condition="$info['login_admin_name'] neq $info['deal_name']">style="display:none;"</if>>立即提交</button>
                    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
            </div>
        </div>
    </form>

    <script>
        layui.use(['layer', 'element', 'form'], function () {
            var layer = layui.layer;
            var element = layui.element;
            var form = layui.form;


            form.on('select(province)', function(data){
                var province_id = data.value;
                if(province_id === '0'){
                    $("#city_id").empty();
//                    $("#city_id").append('<option value=0>默认城市</option>');
                    form.render('select');
                    return false;
                }
                $("#city_id").empty();
                $("#city_id").append('<option value=>请选择城市</option>');
                $.ajax({
                    url:'{:url("/admin/Franchisee/cityList")}',
                    async:true,
                    //dataType:'json',
                    type:'post',
                    data:{'province_id':province_id},
                    success:function(res){
                        $("#city_id").append(res);
                        form.render('select');
                    },
                    error:function(e){
                        layer.msg('请求错误');return false;
                    }
                })
            });

            var type = $("select[name='type']").find("option:selected").val();
            if(type === '1') {
                $("#type_info").css("display","none");
            }
            form.on('select(type)', function(data){
                var type = data.value;
                if(type === '1') {
                    $("#type_info").css("display","none");
                    $("#type_info input").attr("lay-verify","");
                } else {
                    $("#type_info").css("display","");
                    $("#type_info input").attr("lay-verify","required");
                }
            });


            var progress = $("input[name='progress']:checked").val();
            if (progress !== '3') {
                $(".result").css("display", "none");
            }
            form.on('radio(progress)', function(data){
//                var val = $('input:radio[name="progress"]:checked').val();
                var progress = data.value;
                if(progress !== '3') {
                    $(".result").css("display", "none");
                    $("textarea[name='remark']").attr("lay-verify", "");
                } else {
                    $(".result").css("display", "");
                    $("textarea[name='remark']").attr("lay-verify", "required");
                }
            });
        });


        var val = $("input[name='car_num']").val();
        if(val === '0') {
            $("input[name='car_model']").css('display', 'none');
            $("input[name='car_model']").attr('lay-verify','');
        }

        function changeInfo() {
            var val = $("input[name='car_num']").val();

            if(val === '0') {
                $("input[name='car_model']").css('display', 'none');
                $("input[name='car_model']").attr('lay-verify','');
            } else {
                $("input[name='car_model']").css('display', '');
                $("input[name='car_model']").attr('lay-verify','required');
            }
        }

    </script>
</block>